//package com.own.demo.elastic;
//
//import com.alibaba.fastjson.JSONObject;
//import com.own.demo.utils.FileToStringUtils;
//import org.apache.http.HttpHost;
//import org.elasticsearch.action.index.IndexRequest;
//import org.elasticsearch.client.RequestOptions;
//import org.elasticsearch.client.RestClient;
//import org.elasticsearch.client.RestHighLevelClient;
//import org.elasticsearch.common.xcontent.XContentType;
//
//
//import java.io.File;
//import java.io.FileReader;
//import java.io.IOException;
//import java.util.Map;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import org.geotools.feature.FeatureCollection;
//
//public class GeoJsonToElasticsearch {
//    private static RestHighLevelClient client;
//
//    public static void main(String[] args) throws Exception {
//        // 初始化 Elasticsearch 客户端
//        client = new RestHighLevelClient(
//                RestClient.builder(
//                        new HttpHost("101.43.251.27", 19200, "http")
//                )
//        );
//
//        String data= FileToStringUtils.txt2String(new File("D:\\dkSpace\\油库规划\\路网\\水.geojson"));
//        JSONObject geoJson = JSONObject.parseObject(data);
//        System.out.println(geoJson);
//        // 读取 GeoJSON 文件
////        ObjectMapper objectMapper = new ObjectMapper();
////        FileReader fileReader = new FileReader("path/to/your/geojson/file.geojson");
////        FeatureCollection featureCollection = objectMapper.readValue(fileReader, FeatureCollection.class);
////
////        // 遍历 Feature 集合
////        for (Feature feature : featureCollection.getFeatures()) {
////            Map<String, Object> properties = feature.getProperties();
////            Object geometry = feature.getGeometry();
////
////            // 构建文档，所有字段名转换为小写
////            String json = "{"
////                    + "\"remark\": \"" + properties.get("REMARK") + "\","
////                    + "\"shape_leng\": " + properties.get("Shape_Leng") + ","
////                    + "\"shape_area\": " + properties.get("Shape_Area") + ","
////                    + "\"layer\": \"" + properties.get("layer") + "\","
////                    + "\"path\": \"" + properties.get("path") + "\","
////                    + "\"geometry\": " + geometry.toString()
////                    + "}";
////
////            // 创建索引请求
////            IndexRequest indexRequest = new IndexRequest("geo_data")
////                    .source(json, XContentType.JSON);
////
////            // 执行索引请求
////            client.index(indexRequest, RequestOptions.DEFAULT);
////        }
////
////        // 关闭客户端
////        client.close();
//    }
//}
//
